package com.demo.controller;

import com.demo.producer.KafkaProducerClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @Date: 2020/3/4 21:46
 * @description: 1.0
 */
@Slf4j
@RestController
public class TestController {
    @Resource
    private KafkaProducerClient kafkaProducerClient;

    @RequestMapping("/test")
    public String test(){
        try {
            // 严格来讲是要在service层写的，这里偷懒一下吧
            kafkaProducerClient.pushMsg("test", UUID.randomUUID().toString(),UUID.randomUUID().toString());
        } catch (Exception e) {
            log.error(e.getMessage(),e);
        }
        return "{}";
    }
}
